import cv2 as cv

from DeepSORT.deepSORT import DeepSORT
from Detector.detector import Detector


def demo():
    from config.paths import TEST_VIDEO2_PATH, DETECTOR, TEST_VIDEO_PATH

    detector = Detector(onnx_path=DETECTOR["ONNX_PATH"])
    deepsort = DeepSORT()

    cap = cv.VideoCapture(TEST_VIDEO_PATH)
    while cap.isOpened():
        success, frame = cap.read()
        if success:
            output_tensors = detector(frame)
            outputs = deepsort.update(output_tensors, frame)
            print(outputs)
            if cv.waitKey(1) == ord('q'):
                break
    cap.release()
    cv.destroyAllWindows()


if __name__ == '__main__':
    demo()


